package com.huarui.user.service;

import java.util.List;

import com.huarui.company.model.Company;
import com.huarui.employee.model.Employee;
import com.huarui.user.model.SessionMessage;
import com.huarui.user.model.User;

public class SessionMessageService {

	private SessionMessage sessionMessage;

	public void setSessionMessage(SessionMessage sessionMessage) {
		this.sessionMessage = sessionMessage;
	}

	public SessionMessage getSessionMessage(User user, Employee employee,
			Company company, List<Integer>  roleIds) {
		sessionMessage = new SessionMessage();
		sessionMessage.setCompanyId(user.getCompanyId());
		sessionMessage.setCompanyName(company.getName());
		sessionMessage.setLogined(true);
		sessionMessage.setUserEmail(user.getEmail());
		sessionMessage.setUserId(user.getId());
		sessionMessage.setRoles(employee.getRoles());
		sessionMessage.setUserLoginTimes(user.getLoginTimes());
		sessionMessage.setUserLastLoginTime(user.getGmtLastLogin());
		sessionMessage.setUserPy(user.getPyCode());
		sessionMessage.setUserIdent(user.getIdent());
		sessionMessage.setUserName(user.getName());
		sessionMessage.setCompanyStatus(company.getStatus());
		sessionMessage.setEmployeeId(employee.getId());
		sessionMessage.setCompanyType(company.getCompanyType());
		sessionMessage.setRoleIds(roleIds);
		sessionMessage.setAuthenticationCompany(company.getRealType());
		return sessionMessage;
	}

	public SessionMessage getSessionMessage(User user) {
		sessionMessage = new SessionMessage();
		sessionMessage.setLogined(true);
		sessionMessage.setUserEmail(user.getEmail());
		sessionMessage.setUserId(user.getId());
		sessionMessage.setUserLoginTimes(user.getLoginTimes());
		sessionMessage.setUserLastLoginTime(user.getGmtLastLogin());
		sessionMessage.setUserPy(user.getPyCode());
		sessionMessage.setUserIdent(user.getIdent());
		sessionMessage.setUserName(user.getName());
		return sessionMessage;
	}

}
